import win32gui
import win32con
import time

handler = win32gui.FindWindow(None, "Microsoft Word")
print(win32gui.GetClassName(handler))
print(win32gui.GetWindowText(handler))

button_yes_handler = win32gui.FindWindowEx(handler, 0, None, "确定")
print(win32gui.GetWindowText(button_yes_handler))
print(win32gui.GetClassName(button_yes_handler))

msg = win32gui.SendMessage(button_yes_handler, win32con.BM_CLICK, 0, 0)
msgs = win32gui.SendMessage(button_yes_handler, win32con.BM_CLICK, 0, 0)


# time.sleep(60)
# print('sleep end-----')
